

//
//  BACollectionView.m
//  BabyAlbum
//
//  Created by master on 17/3/2.
//  Copyright © 2017年 master. All rights reserved.
//

#import "BACollectionView.h"

@interface BACollectionView ()

@property (nonatomic, strong) UIView *bgView;

@end

@implementation BACollectionView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout {
    self = [super initWithFrame:frame collectionViewLayout:layout];
    self.bgView = [[UIView alloc] init];
    self.bgView.backgroundColor = [UIColor whiteColor];
    self.bgView.clipsToBounds = YES;
    self.bgView.cornerRadius = 10;
    self.bgView.alpha = 1;
    [self addSubview:self.bgView];
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    NSLog(@"%@",self.subviews);
    self.bgView.frame = CGRectMake(0, 10, self.contentSize.width, self.contentSize.height - 10);
    for (UIView *subView in self.subviews) {
        if(subView != self.bgView) {
            [self bringSubviewToFront:subView];
        }
    }}

@end
